package com.example.firstfive;

import android.app.ListActivity;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.os.Message;
import android.widget.ArrayAdapter;
import android.widget.ListAdapter;

import java.util.ArrayList;
import java.util.List;


public abstract class MyListActivity4 extends ListActivity {
    private static final String TAG = "提示";
    Handler handler;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        List<String> list1 = new ArrayList<String>();
        for (int i = 1; i < 100; i++) {
            list1.add("item" + i);
        }
        String[] list_data = {"one", "two", "three", "four"};
        ListAdapter adapter = new ArrayAdapter<String>(this,
                android.R.layout.simple_list_item_1, list1);
        setListAdapter(adapter);

        handler = new Handler(Looper.myLooper()) {
            @Override
            public void handleMessage(Message msg) {
                //super.handleMessage(msg);
                if (msg.what == 5) {
                    List<String> list2 = (List<String>) msg.obj;
                    ListAdapter adapter = new ArrayAdapter<String>(MyListActivity4.this,
                            android.R.layout.simple_list_item_1, list_data);
                    setListAdapter(adapter);
                }
                super.handleMessage(msg);


            }
        };
        //开启子线程
        MapTask myTask = new MapTask();
        myTask.setHandler(handler);
        Thread t = new Thread(myTask);
        t.start();//myTask.run();
        // Thread t = new Thread(this);
        // t.start();//this.run();

    }
}